﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Esint.Common.Data;
using System.Data.SqlClient;

namespace Esint.JudicialAuction.SqlDAL
{
    internal class OperateObject:IOperateObject
    {
        public OperateObject()
        {

        }

        public OperateObject(DataQuery dataQuery)
        {
            this.SqlText = dataQuery.SQLText;

            if (dataQuery.WhereParameters != null && dataQuery.WhereParameters.Count > 0)
            {
                //转化参数
                foreach (var par in dataQuery.WhereParameters)
                {
                    IDataParameter temp = new SqlParameter() { ParameterName = par.ParameterName, Value = par.Value };
                    this.Parameters.Add(temp);
                }
            }
            
        }


        /// <summary>
        /// 执行的SQL语句
        /// </summary>
        public string SqlText { get; set; }

        /// <summary>
        /// SQL语句对应的参数列表
        /// </summary>
        private List<IDataParameter> paras;
        public List<IDataParameter> Parameters
        {
            get
            {
                if (paras == null)
                    paras = new List<IDataParameter>();
                return paras;
            }
            set
            {
                paras = value;
            }
        }
    }
}
